﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QLNHASACH.DTO;
using QLNHASACH.BussinessLayer.ObjectBUS;

namespace QLNHASACH.PresentationLayer.Controls
{
    public partial class DangNhapCtrl : UserControl
    {
        public DangNhapCtrl()
        {
            InitializeComponent();
        }

        private void btDangNhap_Click(object sender, EventArgs e)
        {
            if (txbTenDangNhap.Text != "")
            {
                Utilitiles.User = NguoiDungBUS.LayThongTinNguoiDung(txbTenDangNhap.Text);
                if (Utilitiles.MaHoaMD5(txbMatKhau.Text) == Utilitiles.User.MatKhau)
                {
                    lbStatus.Text = "Đăng nhập thành công..!";
                    //this.Visible = false;
                }
                else lbStatus.Text = "Sai mật khẩu..!";
            }
            else lbStatus.Text = "Bạn chưa nhập..!";
        }
        private void txbMatKhau_TextChanged(object sender, EventArgs e)
        {
            Utilitiles.User = NguoiDungBUS.LayThongTinNguoiDung(txbTenDangNhap.Text);
            if (Utilitiles.User.MatKhau == Utilitiles.MaHoaMD5(txbMatKhau.Text))
            {
                pbTick2.Visible = true;
            }
            else
                pbTick2.Visible = false;
        }
    }
}
